interface RankFunction {
  onSearch(): void;
  onTabChange(detail: any): void;
  addUpHandler(): void;
}
interface RankData {
  value: string;
  tab: string;
  headerList: Array<string>;
  upList: Array<any>;
  model: Object;
}

// 排行榜页面数据
Page<RankData, RankFunction>({
  data: {
    tab: "0", // 选项卡的索引
    value: "", // 输入框的值
    headerList: ["排名", "UP主信息", "胡椒指数", "详情"],
    upList: [1, 2, 3, 4, 7, 10], // up主列表
    model: {
      fans: "新增粉丝",
      likes: "新增点赞",
      collects: "新增收藏",
      comments: "新增评论",
    },
  },
  // 搜索回调
  onSearch() {},
  // 选项卡切换
  onTabChange({ detail }: any) {
    const index = detail.name;
    const data = this.data.headerList;
    data.splice(2, 1, index === "1" ? "粉丝增量" : "胡椒指数");
    this.setData({
      headerList: data,
    });
  },
  addUpHandler() {
    wx.navigateTo({
      url: "/package/add-up/index",
    });
  },
});
